package http.handler;

import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.handler.codec.http.FullHttpRequest;

@ChannelHandler.Sharable
public class HttpServerHandler extends ChannelInboundHandlerAdapter {

    @Override
    public void channelRead(ChannelHandlerContext ctx, Object req) throws Exception {
        if(req instanceof  FullHttpRequest){
            System.out.println("io thread:"+Thread.currentThread());
            FullHttpRequest request= (FullHttpRequest) req;
            String msg = "收到请求uri：" + request.uri();
            System.out.println(msg);
            System.out.println("HttpServerHandler.this:"+this);
            System.out.println("HttpServerHandler thread:" + Thread.currentThread());
            request.release();
        }else{
            System.out.println("no");
        }
    }

//    @Override
//    protected void channelRead0(ChannelHandlerContext ctx, FullHttpRequest req) throws Exception {
//        String msg = "收到请求uri：" + req.uri();
//        System.out.println(msg);
//        System.out.println("HttpServerHandler.this:"+this);
//        System.out.println("HttpServerHandler thread:" + Thread.currentThread());
//    }



}
